import { mapGetters } from "vuex"
import { queryInfo } from "@/api/sysindex"

export const mixin2 = {
    props: ["riverId", "indexName", "indexId", "audit"],
    computed: {
        ...mapGetters(["permissions"]),
    },
    data() {
        return {
            formData: new FormData(),
            isExpert: false,
            fillComponent: null,
            indexDescription: null,
            supportMaterial: null
        }
    },
    created() {
        this.getInfo()
        this.isExpert = this.vaildData(this.permissions["river_report_audit"], false)
        if (this.audit != null) {
            this.isExpert = this.audit == 1 ? true : false
        }
        if (this.isExpert) {
            this.fillComponent = (resolve) =>
                require([`@/views/river/IndexComponents/${this.indexName}/fill_expert`], resolve)
        } else {
            this.fillComponent = (resolve) =>
                require([`@/views/river/IndexComponents/${this.indexName}/fill_normal`], resolve)
        }
    },
    methods: {
        changeLoading(val) {
            this.$emit("changeLoading", val)
        },
        refreshIndexList() {
            this.$emit("refreshIndexList")
        },
        getInfo() {
            let indexCode = this.indexName.slice(0, this.indexName.length - 5)
            queryInfo(indexCode).then(res => {
                let data = res.data.data
                if(data != null) {
                    this.indexDescription = data.indexDescription
                    this.supportMaterial = data.supportMaterial
                }
            })
        }
    },
}